package impl

import (
	"context"
	"fmt"
	"kubernetes-manage/apps/cluster"
)

func (s *service) insert(ctx context.Context, t *cluster.ClusterInfo) error {

	stmt, err := s.db.Prepare(insertClusterSQL)
	if err != nil {
		return err
	}
	defer stmt.Close()

	_, err = stmt.Exec(
		t.Id, t.CreateAt, t.ClusterVersion, t.ClusterName, t.KubeConfig, t.Node.NodeName, t.Node.NodeIp, t.Node.NodeStatus,
	)
	if err != nil {
		return fmt.Errorf("save cluster_info error, %s", err)
	}
	return nil
}
